package view
{
	import assets.view.HeaderViewSymbol;
	
	import flash.display.Graphics;
	import flash.geom.Vector3D;
	import flash.text.TextFieldAutoSize;
	
	import model.vo.ViewVO;

	public class HeaderView extends HeaderViewSymbol
	{
		public static const NAME:String 				= "HeaderView";
		
		public static const CLICKED:String				= NAME + "Clicked";
		
		private var viewData:ViewVO;
		
		private var headerWidth:Number;
		private var headerHeight:Number;
		
		private var headerViewVecArt:Vector.<Vector3D>;
		
		public function HeaderView()
		{
			this.alpha = 1;
		}
		
		public function init( viewVO:ViewVO ):void
		{
			viewData = viewVO;
			
			setHeaderViewProperties();
			buildHeaderView();
		}
		
		private function setHeaderViewProperties():void
		{
			headerWidth 	= viewData.HEADER_WIDTH;
			headerHeight 	= viewData.HEADER_HEIGHT;
		}
		
		private function buildHeaderView():void
		{
			label1.alpha		= 0;
			label1.autoSize 	= TextFieldAutoSize.LEFT;
			label1.text		 	= viewData.HEADER_TEXT;
			
			label2.alpha		= 0;
			label2.autoSize 	= TextFieldAutoSize.LEFT;
			label2.text 		= viewData.HEADER_TEXTFALLOUT;
			
			headerViewVecArt = new Vector.<Vector3D>();
			
			headerViewVecArt.push( new Vector3D( 0, 0 ) );
			headerViewVecArt.push( new Vector3D( headerWidth, 0 ) );
			headerViewVecArt.push( new Vector3D( headerWidth, headerHeight ) );
			headerViewVecArt.push( new Vector3D( 0, headerHeight ) );
			
			FX.spawnHeader( frameContainer, label1, label2, headerViewVecArt, headerSpawnCompleteHandler, viewData );
		}
		
		private function headerSpawnCompleteHandler():void
		{
			var g:Graphics = frameContainer.graphics;
			g.clear();
			g.lineStyle( viewData.LINE_WEIGHT, viewData.LINE_COLOR );
			g.drawRect( 0, 0, headerWidth, headerHeight );
		}
	}
}